#ifndef symPict_h__
#define symPict_h__
#include "../skyAdapter.h"
#ifdef _SYMBIAN

#include <e32base.h>	// For CActive, link against: euser.lib
#include <e32std.h>		// For RTimer, link against: euser.lib
#include <f32file.h>
#include <fbs.h>
#include <ImageConversion.h>
#include <coemain.h>
namespace Sky
{
	// INCLUDES


	// CLASS DECLARATION

	/**
	*  myImageDecode
	* 
	*/
	class ImageDecode : public CActive
	{
	public:
		enum TImageType{
			ImagePng = 0,
			ImageJpg
		};
	public:
		~ImageDecode();
		// Two-phased constructor.
		static ImageDecode* NewL(RFs& aFs);

		// Two-phased constructor.
		static ImageDecode* NewLC(RFs& aFs);

	public:
		TBool LoadImageL(const TDesC& aFileName, CFbsBitmap** aBitmap,TImageType aImageType = ImageJpg);
		TBool LoadImageL(const TDesC& aFileName, CFbsBitmap** aBitmap, CFbsBitmap** aBitmapMask,TImageType aImageType = ImageJpg);
		TBool LoadBufferedImageL(const TDesC8& aBuffer , CFbsBitmap** aBitmap,TImageType aImageType = ImageJpg);
		TBool LoadBufferedImageL(const TDesC8& aBuffer , CFbsBitmap** aBitmap, CFbsBitmap** aBitmapMask,TImageType aImageType = ImageJpg);

	private:
		// C++ constructor
		ImageDecode(RFs& aFs);

		// Second-phase constructor
		void ConstructL();

	private:
		void RunL();
		void DoCancel();
		TInt RunError(TInt aError);

	private:
		RFs& iFs;
		CActiveSchedulerWait* iActiveSchedulerWait;
		CImageDecoder* iImgDecoder;
		CBufferedImageDecoder* iBufferedImgDecoder;
	};

	typedef RefPtr<ImageDecode> ImageDecoderPtr;
	typedef CFbsBitmap Bitmap;

	class OSPictManager : public Object
	{
	protected:
		ImageDecode* _decoder;
		ImageDecode* getDecoder()
		{
			if(_decoder == vNull)
				_decoder = ImageDecode::NewL(CCoeEnv::Static()->FsSession());
			return _decoder;
		}
	public:
		OSPictManager():_decoder(vNull){}
		~OSPictManager()
		{
			if(_decoder)
			{
				delete _decoder;
				_decoder = vNull;
			}
		}
	};
	class OSPict : public Object
	{
		friend class ImageDecode;
		friend class Canvas;
		friend class PictManager;
	public:
		OSPict():_bitmap(vNull),_bitmapMask(vNull){};
		~OSPict(void);
	public:
		Bitmap* getBitmap(){return _bitmap;}
		Bitmap* getBitmapMask(){return _bitmapMask;}
	protected:
		Bitmap*  _bitmap;
		Bitmap*  _bitmapMask;
	public:
	};
}
#endif //_SYMBIAN
#endif
